﻿using System;
using System.Collections;
using System.Collections.Generic;

using AUV5.Model;
using AUV5.DAL.Interface;

namespace AUV5.DAL.Dao
{
    /// <summary>
    /// 功能：     PaymentHistory业务接口的实现
    /// 作者：     Wilson
    /// 日期：     2011/11/14
    /// 修改日期： 
    /// 修改人：
    /// 修改内容：
    /// </summary>
    public class PaymentHistorySqlMapDao : BaseSqlMapDao, AUV5.DAL.Interface.IPaymentHistoryDao
    {
        private static PaymentHistorySqlMapDao instance = new PaymentHistorySqlMapDao();

        private PaymentHistorySqlMapDao()
        {
            //
            // TODO: 此处添加PaymentHistorySqlMapDao的构造函数
            //
        }

        public static IPaymentHistoryDao GetInstance()
        {
            return instance;
        }

        /// <summary>
        /// 得到最大行数
        /// </summary>
        /// <returns></returns>
        public int GetMaxCounts()
        {
            try
            {
                return (int)ExecuteQueryForObject("SelectPaymentHistoryByMaxCounts", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到列表
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.IList<PaymentHistory> GetList()
        {
            try
            {
                return ExecuteQueryForList<PaymentHistory>("SelectPaymentHistory", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 通过不同参数得到列表
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public System.Collections.Generic.IList<PaymentHistory> GetListByParameters(object objParameters)
        {
            try
            {
                return ExecuteQueryForList<PaymentHistory>("SelectPaymentHistoryByParameters", objParameters);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到明细
        /// </summary>
        /// <param name="HistoryId"></param>
        /// <returns></returns>
        public PaymentHistory GetDetail(System.String historyid)
        {
            try
            {
                return ExecuteQueryForObject<PaymentHistory>("SelectPaymentHistory", historyid) as PaymentHistory;
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="paymenthistory"></param>
        /// <returns></returns>
        public object Add(PaymentHistory paymenthistory)
        {
            //int id = GetId("PaymentHistory");
            //paymenthistory.HistoryId = id;

            try
            {
                return ExecuteInsert("InsertPaymentHistory", paymenthistory);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="paymenthistory"></param>
        /// <returns></returns>
        public int Update(PaymentHistory paymenthistory)
        {
            try
            {
                return ExecuteUpdate("UpdatePaymentHistory", paymenthistory);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="HistoryId"></param>
        /// <returns></returns>
        public int Delete(System.String historyid)
        {
            try
            {
                return ExecuteDelete("DeletePaymentHistory", historyid);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="paymenthistory"></param>
        /// <returns></returns>
        public int Delete(PaymentHistory paymenthistory)
        {
            try
            {
                return ExecuteDelete("DeletePaymentHistory", paymenthistory.HistoryId);
            }
            catch
            {
                throw;
            }
        }
    }
}
